package com.example.demo1.common;

import jakarta.validation.Path;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;


public enum ResultCode {

    SUCCESS(200, "成功"),

    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),

    INTERNAL_ERROR(500, "服务器内部错误"),

    // 业务错误
    ORGANIZATION_NOT_FOUND(1001, "组织机构不存在"),
    PARENT_NOT_EXIST(1002, "父节点不存在"),
    HAS_CHILDREN(1003, "存在子节点不能删除"),
    CIRCULAR_REFERENCE(1004, "循环引用"),
    INVALID_PATH_FORMAT(1005, "路径格式不正确"),
    NAME_ALREADY_EXISTS(1006, "组织名称已存在"),
    PATH_INTEGRITY_ERROR(1007, "路径完整性错误");

    int code;
    String message;
    ResultCode(int code,String message){
        this.code=code;
        this.message=message;
    }

    @Override
    public String toString() {
        return "ResultCode{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
    public int getCode(){
        return code;
    }
    public String getMessage(){
        return message;
    }

}
